#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2025/9/2
# @Author  : YunZhen
# @File    : _model.py
# @Software: PyCharm
"""
数据模型定义
"""
from datetime import datetime
from pydantic import BaseModel, Field
from typing import Dict, Optional


class VersionInfo(BaseModel):
    """版本信息模型"""
    url: str = Field(..., description="下载URL")
    size: str = Field(..., description="文件大小")
    md5: str = Field(..., description="MD5校验值")
    sha256: str = Field(..., description="SHA256校验值")
    release_date: str = Field(..., description="发布日期")


class PlatformInfo(BaseModel):
    """平台信息模型"""
    version: Dict[str, VersionInfo] = Field(..., description="版本信息字典")


class PlatformData(BaseModel):
    """平台数据模型"""
    windows: PlatformInfo = Field(..., description="Windows平台信息")


class RootModel(BaseModel):
    """根模型"""
    platform: PlatformData = Field(..., description="平台数据")
    update: datetime = Field(..., description="最后更新时间")

    class Config:
        json_encoders = {
            datetime: lambda v: v.strftime('%Y-%m-%d %H:%M:%S')
        }
